const weapons = [
    // {
    //     name: "纳甲大刀(传奇)",
    //     cutConefficient: 1.1,
    //     butConefficient: 2.8,
    //     quickMode: true,
    //     throuthArmot: 15 1
    // },
    // {
    //     name: "大屠杀(传奇)",
    //     cutConefficient: 2.1,
    //     butConefficient: 1.2,
    //     throuthArmot: 20,
    //     effect: {
    //         human: 15
    //     }
    // },
    // {
    //     name: "液压泰坦锤(传奇)",
    //     cutConefficient: 1.78,
    //     butConefficient: 1.6,
    //     throuthArmot: 25
    // },
    {
        name: "落日(名刃)",
        cutConefficient: 2.64,
        butConefficient: 2.0,
        throuthArmot: 0,
    },
    // {
    //     name: "平板剑(名刃)",
    //     cutConefficient: 1.76,
    //     butConefficient: 2.4,
    //     throuthArmot: 0,
    // },
    // {
    //     name: "分段斧(名刃)",
    //     cutConefficient: 0.66,
    //     butConefficient: 3.6,
    //     throuthArmot: 0,
    // },
    // {
    //     name: "长砍刀(刃三)",
    //     cutConefficient: 1.4,
    //     butConefficient: 1.36,
    //     throuthArmot: 30
    // },
    // {
    //     name: "圣骑士十字(名刃)",
    //     cutConefficient: 1.76,
    //     butConefficient: 1.6,
    //     throuthArmot: 30,
    //     effect: {
    //         robot: 30,
    //         human: -20
    //     }
    // },
    // {
    //     name: "长柄刀(名刃)",
    //     cutConefficient: 1.1,
    //     butConefficient: 1.0,
    //     quickMode: true,
    //     throuthArmot: 30
    // }
]

weapons.map(weapon => {
    kenshipoint({
        weapon,
        skill: {
            power: 50,
            agile: 50,
            mastery: 50
        }
    })
})

function kenshipoint(props) {
    let {
        weapon,
        skill
    } = props
    let {
        power,
        agile,
        mastery
    } = skill
    let {
        cutConefficient,
        butConefficient,
        throuthArmot,
        quickMode,
        effect
    } = weapon
    let dmg;
    let k = 0.65
    if (cutConefficient < butConefficient) { // 说明主要伤害是冲击
        dmg = {
            mainDamage: {
                type: "冲击",
                damage: (20 + (0.45 * butConefficient * (power + mastery*0.33))) * k
            },
            secondaryDamage: {
                type: "切割",
                damage: (8 + (0.35 * cutConefficient * (agile + mastery))) * k
            }
        }
    } else { // 主要伤害是切割
        dmg = {
            mainDamage: {
                type: "切割",
                damage: (20 + (0.3 * cutConefficient * (agile + mastery))) * k
            },
            secondaryDamage: {
                type: "冲击",
                damage: (0 + (0.6 * butConefficient * (power + mastery*0.33))) * k
            }
        }
    }
    console.log(dmg);
    let armor = {
        butDenf: 61 * (100 - (throuthArmot || 0)) / 100,
        cutDenf: 81 * (100 - (throuthArmot || 0)) / 100,
        cutTurn: 90
    }
    let keys = []
    if (effect) {
        for (const key in effect) {
            keys.push(key)
            const element = effect[key];
            dmg.mainDamage[key] = dmg.mainDamage.damage * (100 + element) / 100
            dmg.secondaryDamage[key] = dmg.secondaryDamage.damage * (100 + element) / 100
        }
    }
    let cutDmg = (dmg.mainDamage.type == "切割") ? dmg.mainDamage : dmg.secondaryDamage
    let butDmg = (dmg.mainDamage.type == "冲击") ? dmg.mainDamage : dmg.secondaryDamage
    let butSh = butDmg.damage - butDmg.damage * (armor.butDenf / 100)
    let tmpCut = cutDmg.damage * (armor.cutDenf / 100)
    let cutSh = cutDmg.damage - tmpCut
    butSh += tmpCut * (100 - armor.cutTurn) / 100
    let res = {
        name: weapon.name,
        "面板": (dmg.mainDamage.damage + dmg.secondaryDamage.damage).toFixed(0),
        point: ((butSh + cutSh) * (1 + (quickMode ? 0.2 : 0))).toFixed(0)
    }
    keys.forEach(key => {
        let _cutDmg = (dmg.mainDamage.type == "切割") ? dmg.mainDamage : dmg.secondaryDamage
        let _butDmg = (dmg.mainDamage.type == "冲击") ? dmg.mainDamage : dmg.secondaryDamage
        let _butSh = _butDmg[key] - _butDmg[key] * (armor.butDenf / 100)
        let _tmpCut = _cutDmg[key] * (armor.cutDenf / 100)
        let _cutSh = _cutDmg[key] - _tmpCut
        _butSh += _tmpCut * (100 - armor.cutTurn) / 100
        res[key] = ((_butSh + _cutSh) * (1 + (quickMode ? 1.2 : 0))).toFixed(0)
    })
    return res
}